package hcontroller

import (
	"advertoper/controllers"
	// "advertoper/errorcode"
	"advertoper/homepageinfo/hservice"
)

type TemporaryPassortController struct {
	controllers.URLSignController
}

//客户端来查询临时账号是否存在
// @router /check [get]
func (p *TemporaryPassortController) PassportCheck() {
	defer p.Output("PassportCheck")
	p.ForceHTTPS()

	vuid := p.GetString("vuid", "")
	req := &hservice.PassportCheckReq{}
	req.Vuid = vuid
	resp := &hservice.PassportCheckResp{}
	hservice.GetTemporaryPassportService().PassportCheck(req, resp)
	p.Resp["code"] = resp.Code
	p.Resp["msg"] = resp.Msg
	if resp.Code == 0 {
		if resp.IsRegist == 1 {
			p.Resp["is_regist"] = 1 //已经注册过
		} else {
			p.Resp["is_regist"] = 2 //未注册过
			p.Resp["uid"] = resp.Uid
			p.Resp["avater"] = resp.Avatar
			p.Resp["nick_name"] = resp.NickName

		}
	}

}

//登陆上报
//@router /upload [get]
func (p *TemporaryPassortController) LoginUpload() {
	defer p.Output("LoginUpload")
	p.ForceHTTPS()

	vuid := p.GetString("vuid", "")
	uid := p.GetString("uid", "")
	code, msg := hservice.GetTemporaryPassportService().LoginUpload(vuid, uid)
	p.Resp["code"] = code
	p.Resp["msg"] = msg
}
